package com.lovo.test.LicensingSystem;

import com.lovo.test.text.Studends;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DouDiZhu {
    private static ArrayList<Card> list = new ArrayList();

    public static void main(String[] args) {
        DouDiZhu douDiZhu = new DouDiZhu();
        douDiZhu.init();
        douDiZhu.xipai();
        douDiZhu.fapai();


    }

    // 发牌
    public void fapai() {
        List player1 = new ArrayList();
        List player2 = new ArrayList();
        List player3 = new ArrayList();
        List player4 = new ArrayList();
        player1 =  list.subList(0, 17);
        player2 =  list.subList(17, 34);
        player3 = list.subList(34, 51);
        player4 =  list.subList(51, 54);
        for (Object obj : player1) {
            System.out.println("玩家1"+obj);
        }
        for (Object obj : player2) {
            System.out.println("玩家2"+obj);
        }
        for (Object obj : player3) {
            System.out.println("玩家3"+obj);
        }
        for (Object obj : player4) {
            System.out.println("底牌"+obj);
        }


    }

    // 洗牌
    public void xipai() {
        Collections.shuffle(list);
        for (Object obj : list
        ) {
            System.out.println(obj);
        }

    }

    // 初始化54张扑克牌
    public void init() {
        String[] type = {"♠", "♥", "♣", "♦"};
        String[] number = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A","2"};

        list.add(new Card("大王"));
        list.add(new Card("小王"));
        int count = 0;
        for (int i = 0; i < type.length; i++) {
            for (int j = 0; j < number.length; j++) {
                list.add(new Card(type[i], number[j]));
                count++;
            }
        }
        for (Object obj : list) {
            System.out.println(obj);
        }
        System.out.println(count);
    }
}
